﻿// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Widgets/SCompoundWidget.h"


struct ConfigInfo
{
	ConfigInfo(FString filePath,FString fileName): FilePath(filePath), FileName(fileName), IsSaved(true),IsCurrent(false) {}
	
	FString FilePath;
	FString FileName;
	FText ConfigContent;
	bool IsSaved;
	bool IsCurrent;
	TSharedPtr<SButton> ConfigButton;
};

class GKCONFIGEDITOR_API SGKConfigTab : public SCompoundWidget
{
public:
SLATE_BEGIN_ARGS(SGKConfigTab) {}
	SLATE_END_ARGS()

	/** Constructs this widget with InArgs */
	void Construct(const FArguments& InArgs);

	TArray<FDirectoryPath> GetConfigPath();

private:
	void InitConfigButton();
	void AddConfigButton(FString FilePath);
	FReply ClickConfigButton(ConfigInfo* Config);
	FReply ClickSaveButton();
	bool IsImportButtonEnabled(ConfigInfo* Config) const;
	FText GetConfigContentText() const;
	void OnConfigChanged(const FText& NewContent);
	EVisibility IsConfigEdited(ConfigInfo* Config) const;

private:
	ConfigInfo* CurrentConfigIndex;
	TArray<ConfigInfo*> ConfigButtons;
	TSharedPtr<SButton> DeleteButton;
	TSharedPtr<SButton> AddButton;
	TSharedPtr<class SScrollBox> ConfigList;
	TSharedPtr<class SMultiLineEditableTextBox> ConfigContentBox;
};